<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<div class="line-big">
	<div class="xl2"></div>
	<div class="xl8">
		<div class="panel border-back" id="write_special_commission_div">
			<div class="panel-body text-center">
				<h1>
					<strong>批量导入特殊佣金</strong>
				</h1>
			</div>
			<div class="panel-foot bg-white border-back">
				<div class="line-big">
					<div class="xl6">
						<form id="import_special_commission_form" action="admin/m_import_special_commission_do" method="post" enctype="multipart/form-data">
							<input size="100" id="excel_file_input" type="file" name="excelFile"/>
						</form>
					</div>
					<div class="xl6"></div>
				</div>

			</div>
			<div class="panel-foot bg-white">
				<div class="line-big margin-top margin-bottom">
					<div class="xl4"></div>
					<div class="xl4 text-center">
						<button class="button border-blue" id="submit_special_commission_button">导入佣金信息</button>
					</div>
					<div class="xl4"></div>
				</div>
			</div>
			<div class="panel-foot bg-white border-back" style="padding-top: 100px;">
				<div class="line-big">
					<div class="xl6 text-left">
						<h4>
							<strong>注意事项:</strong>
						</h4>
						<ol class="list-cn height">
							<li>
								批量导入模板下载地址：
								<a class="text-blue" target="_blank" href="file/import_special_commission_template.xlsx">点击下载模板</a>
							</li>
							<li>
								批量导入模板数据示例：<br>
								<table class="table table-bordered">
									<tr>
										<th>买家编号(25位)</th>
										<th>商品编号(25位)</th>
										<th>商品特殊佣金(最多两位小数)</th>
									</tr>
									<tr>
										<td>xxx</td>
										<td>xxx</td>
										<td>x.xx</td>
									</tr>
								</table>
							</li>
							<li>每一列的数据都要按要求填写，否则导入出错，后果自负。</li>
							<li>导入的数据如果数据库中没有记录则添加，有记录则修改为文档中的佣金。</li>
						</ol>

					</div>
					<div class="xl6"></div>
				</div>

			</div>
		</div>
		<div id="add_success_div" class="G-MarginTop100" style="display: none;">
			<div class="line-big">
				<div class="xl3"></div>
				<div class="xl6 text-center">
					<h1 class="text-center">
						<span class="icon-check-circle text-yellow"></span> 导入佣金信息成功了。
					</h1>
					<br />
					<p>
						<button class="button bg-blue" id="go_on_add_special_commission">
							<span class="icon-plus-circle"></span> 继续批量导入特殊佣金
						</button>
						<button class="button bg-green margin-top click_go_to_nav_button" data-trigger-id="#sub_see_on_sale_goods">
							<span class="icon-eye"></span> 去查看销售中的商品
						</button>
						<button class="button bg-green margin-top click_go_to_nav_button" data-trigger-id="#sub_see_used_buyer">
							<span class="icon-eye"></span> 去查看使用中的买家
						</button>
					</p>
				</div>
				<div class="xl3"></div>
			</div>
		</div>
	</div>
	<div class="xl2"></div>
</div>
<div style="display: none" id="time_temp_div"></div>

<script type="text/javascript">
	$(function()
	{

		var submit_special_commission_button_html;
		$("#submit_special_commission_button").click(function()
		{

			if (!$("#excel_file_input").val().endWith(".xlsx"))
			{
				alert("请选择后缀为.xlsx的excel文件");
				return false;
			}

			submit_special_commission_button_html = $("#submit_special_commission_button").html();
			$("#submit_special_commission_button").attr("disabled", "disabled");
			$("#submit_special_commission_button").html("正在提交佣金信息中...");
			
			$('#import_special_commission_form').submit();
		});

		$('#import_special_commission_form').ajaxForm(
		{
			success : processJson,
			dataType : 'json',
			clearForm : true
		});

		function processJson(data)
		{
			$("#submit_special_commission_button").removeAttr("disabled");
			$("#submit_special_commission_button").html(submit_special_commission_button_html);

			if (data.success == true)
			{
				$("#write_special_commission_div").slideUp();
				$("#add_success_div").slideDown(function()
				{
					$(".admin").animate(
					{
						scrollTop : 0
					}, 0);
				});
			}
			else
			{
				alert(data.info);
			}

		}


		$("#go_on_add_special_commission").click(function()
		{
			$("#add_success_div").slideUp();
			$("#write_special_commission_div").slideDown(function()
			{
				if ("${param.buyerId }".length <= 0)
				{
					$("#buyerId").val("");
				}
				if ("${param.goodsId }".length <= 0)
				{
					$("#goodsId").val("");
				}
				$("#goodsCommission").val("");
			});
		});

	});
</script>